#include <iostream>
#include <string>
using namespace std;
bool is_prime(int n) {
    if (n <= 1) return false;
    if (n <= 3) return true;
    if (n % 2 == 0 || n % 3 == 0) return false;
    for (int i = 5; i * i <= n; i += 6) {
        if (n % i == 0 || n % (i + 2) == 0) return false;
    }
    return true;
}
int closest_prime(int num) {
    if (num <= 1) return 2;
    int prime = num;
    bool found = false;
    if (is_prime(num)) return num;
    while (!found) {
        prime++;
        if (is_prime(prime)) found = true;
    }
    return prime;
}
int main() {
    string a[3];
    int c;
    for (int i = 0; i < 3; i ++) {
        cin >> c;
        a[i] = c;
    }
    string b = "";
    for (int i = 0; i < 3; i++) {
        if (a[i] == "zero")
            b += "0";
        if (a[i] == "one")
            b += "1";
        if (a[i] == "two")
            b += "2";
        if (a[i] == "three")
            b += "3";
        if (a[i] == "four")
            b += "4";
        if (a[i] == "five")
            b += "5";
        if (a[i] == "six")
            b += "6";
        if (a[i] == "seven")
            b += "7";
        if (a[i] == "eight")
            b += "8";
        if (a[i] == "nine")
            b += "9";
    }
    int num = stoi(b);
    cout << closest_prime(num);
    return 0;
}
